package com.ibeetl.cms.service;

import java.util.List;

import com.ibeetl.cms.entity.DoctoralSubsidy;
import com.ibeetl.cms.entity.OutboundSubsidy;
import com.ibeetl.cms.util.ProcessConstant;
import com.ibeetl.cms.web.query.HighlevelTalentsQuery;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ibeetl.admin.core.util.PlatformException;

import com.ibeetl.cms.dao.HighlevelTalentsDao;
import com.ibeetl.cms.entity.HighlevelTalents;
import com.ibeetl.admin.core.service.BaseService;

/**
 * HighlevelTalents Service
 */

@Service
@Transactional
public class HighlevelTalentsService extends BaseService<HighlevelTalents>{

    @Autowired private HighlevelTalentsDao highlevelTalentsDao;

    public PageQuery<HighlevelTalents>queryByCondition(PageQuery query){
        PageQuery ret =  highlevelTalentsDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelHighlevelTalents(List<Long> ids){
        try {
            highlevelTalentsDao.batchDelHighlevelTalentsByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除HighlevelTalents失败", e);
        }
    }
    public PageQuery<HighlevelTalents> queryEmployees(PageQuery page) {
        page.setPageSize(Integer.MAX_VALUE);

        PageQuery ret =  highlevelTalentsDao.queryEmployees(page);
        queryListAfter(ret.getList());
        return ret;
    }

    //查企业
    public PageQuery<HighlevelTalents>findenterprise(PageQuery query){
        PageQuery ret =  highlevelTalentsDao.findenterprise(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public List<HighlevelTalents>queryCompany(HighlevelTalentsQuery condtion){
        List ret =  highlevelTalentsDao.queryCompany(condtion);
        queryListAfter(ret);
        return ret;
    }
    public PageQuery<HighlevelTalents> queryDoneTask(PageQuery page) {
        PageQuery ret =  highlevelTalentsDao.queryDoneTask(page);
        queryListAfter(ret.getList());
        return ret;

    }

    /**
     *根据用户id查询本年度是否已申请高层次人才申报（用于医疗保障判断）
     */
    public Boolean findYear(Long userId,String year){
        return  highlevelTalentsDao.findYear(userId,year)>0;
    }

    public int queryEmployeesCount(HighlevelTalentsQuery condition) {
        return highlevelTalentsDao.queryEmployeesCount(condition);
    }

    /**
     * 根据user_id查询已生效的高层次人才业务数目
     * @param userId
     * @return
     */
    public  int finddoneStr(Long userId){
        return highlevelTalentsDao.finddoneStr(userId, ProcessConstant.DONE);
    }
}